package com.ews.onlineexchange.controller;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Inject;
import javax.inject.Named;

import com.ews.onlineexchange.model.Bulletin;
import com.ews.onlineexchange.model.ContractRecord;
import com.ews.onlineexchange.service.EntityHome;

@Named
@ConversationScoped
public class ContractRecordHome extends EntityHome<ContractRecord, String> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Inject
	BulletinHome3 bulletinHome3;

	@Override
	public String saveAndFlush() {
		Bulletin bulletin = bulletinHome3.getInstance();
		getInstance().setBulletin(bulletin);
		getInstance().setProjectName(bulletin.getProjectName());
		getInstance().setBuyerName(bulletin.getBuyer().getCnname());
		getInstance().setSupplierName(bulletin.getSuccessTrade().getSupplier().getCnname());
		return super.saveAndFlush();
	}

//	@PostConstruct
//	public void init() {
//				Bulletin bulletin = bulletinHome3.getInstance();
//				this.getInstance().setBulletin(bulletin);
//				getInstance().setProjectName(bulletin.getProjectName());
//				getInstance().setBuyerName(bulletin.getBuyer().getCnname());
//				getInstance().setSupplierName(bulletin.getSuccessTrade().getSupplier().getCnname());
//	}
	
}
